import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () =>
    import ('../vires/home/Home')
const Cart = () =>
    import ('../vires/cart/Cart')
const Category = () =>
    import ('../vires/category/Category')
const Profile = () =>
    import ('../vires/profile/Profile')
const Detail = () =>
    import ('../vires/detail/Detail')

const routes = [{
        path: '',
        redirect: '/home'
    },
    {
        path: '/home',
        component: Home
    },
    {
        path: '/cart',
        component: Cart
    },
    {
        path: '/profile',
        component: Profile
    },
    {
        path: '/category',
        component: Category
    },
    {
        path: '/detail/:iid',
        component: Detail
    }

]

const router = new VueRouter({
    routes,
    mode: 'history'
})

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

export default router